package org.buptsse.listview;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;

import org.buptsse.entity.User;

import org.buptsse.ui.MyAllBooksActivity;
import org.buptsse.ui.NearBookAllActivity;
import org.buptsse.ui.PostNewBookActivity;
import org.buptsse.ui.R;
import org.buptsse.ui.SearchActivity;
import org.buptsse.ui.TestActivity;

import android.app.SearchableInfo;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.Toast;

public class HomePage extends LinearLayout implements OnClickListener {
	private final String SAVE_PATH = "/mnt/sdcard/tmp/";
	private View view;
	private User user = null;
	private Button quwen, guanzhu, fansi,inforSet,circleCreate;
	private Context context;
	private ImageView headImage = null;

	private Button nearbyBookBT,searchBookBT,publishBookBT,bookManageBT;
	
	public HomePage(Context context, AttributeSet attrs) {
		super(context, attrs);
		init();
	}

	public HomePage(Context context, User user) {
		super(context);
		this.context = context;
		this.user = null;
		init();
	}

	private void init() {
		LayoutInflater inflater = LayoutInflater.from(getContext());
		view = inflater.inflate(R.layout.ltradecenter, null);
		nearbyBookBT=(Button) view.findViewById(R.id.nearby_book_bt);
		searchBookBT=(Button) view.findViewById(R.id.search_book_bt);
		publishBookBT=(Button) view.findViewById(R.id.publish_book_bt);
		bookManageBT=(Button) view.findViewById(R.id.book_manage_bt);
		nearbyBookBT.setOnClickListener(this);
		searchBookBT.setOnClickListener(this);
		publishBookBT.setOnClickListener(this);
		bookManageBT.setOnClickListener(this);
		LayoutParams params = new LayoutParams(LayoutParams.FILL_PARENT,
				LayoutParams.FILL_PARENT);
		addView(view, params);
	}

	
	
	@Override
	public void onClick(View v) {
		Intent it = new Intent();
		switch (v.getId()) {
		case R.id.nearby_book_bt:
			//附近图书
			it.setClass(context, NearBookAllActivity.class);
			context.startActivity(it);
			break;
		case R.id.search_book_bt:
			//挑选图书
			it.setClass(context, SearchActivity.class);
			context.startActivity(it);
			break;
		case R.id.publish_book_bt:
			it.setClass(context, PostNewBookActivity.class);
			context.startActivity(it);
			//发布新书
			break;
		case R.id.book_manage_bt:
			//管理图书
			it.setClass(context, MyAllBooksActivity.class);
			context.startActivity(it);
			break;
		}
	}

}
